/**
 * 
 * 
 * @author 吕婧
 *
 */
package com.ccb.lms.dao;

import java.sql.SQLException;
import java.util.List;

import com.ccb.lms.model.SystemAdmin;
import com.ccb.lms.util.BasePage;
import com.ibatis.sqlmap.client.SqlMapClient;

@SuppressWarnings("unchecked")
public class SystemAdminDAO implements ISystemAdminDAO {

	private SqlMapClient sqlMapClient = null;
	
	public boolean deleteSystemAdmin(Integer systemAdminNO) throws SQLException {
		sqlMapClient.delete("systemAdmin.deleteSystemAdmin", systemAdminNO);
		return true;
	}

	public List<SystemAdmin> getAllSystemAdmin() throws SQLException {
		List<SystemAdmin> list = null;
		list = sqlMapClient.queryForList("systemAdmin.getAllSystemAdmin");
		return list;
	}

	public SystemAdmin getSystemAdminByID(String systemAdminID) throws SQLException {
		SystemAdmin systemAdmin = null;
		systemAdmin = (SystemAdmin) sqlMapClient.queryForObject("systemAdmin.getSystemAdminByID", systemAdminID);
		return systemAdmin;

	}
	

	public List<SystemAdmin> getSystemAdminByPage(BasePage basePage) throws SQLException {
		List<SystemAdmin> list = null;
		list=sqlMapClient.queryForList("systemAdmin.getSystemAdminByPage", basePage);
		return list;
	}

	
	public int getSystemAdminCount() throws SQLException {
		
		return (Integer)sqlMapClient.queryForObject("systemAdmin.recordCount");
	}

	public boolean insertSystemAdmin(SystemAdmin systemAdmin) throws SQLException {
		sqlMapClient.insert("systemAdmin.insertSystemAdmin", systemAdmin);
		return true;

	}

	public boolean isLogin(SystemAdmin systemAdmin) throws SQLException {
		SystemAdmin sa = (SystemAdmin) sqlMapClient.queryForObject("systemAdmin.checkSystemAdmin", systemAdmin);
		if (sa != null) {
			return true;
		}

		return false;
	}

	public boolean updateSystemAdmin(SystemAdmin systemAdmin) throws SQLException {
		sqlMapClient.update("systemAdmin.updateSystemAdmin", systemAdmin);
		return true;

	}

	public BasePage getBasePage(int currentPage, int showRecordNum) throws SQLException {
		return new BasePage(currentPage,getSystemAdminCount(),showRecordNum);
	}

	public SqlMapClient getSqlMapClient() throws SQLException {
		return sqlMapClient;
	}

	public void setSqlMapClient(SqlMapClient sqlMapClient) {
		this.sqlMapClient = sqlMapClient;
	}

}